﻿using log4net;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Weight.Base
{
   public static class LogHelper
    {
        private  static ILog logError = LogManager.GetLogger("ErrorLog");
        private static ILog logInfor = LogManager.GetLogger("InforLog");

        public static void Init(string sysConfig)
        {
            log4net.Config.XmlConfigurator.Configure(new  FileInfo(sysConfig));
        }
        /// <summary>
        /// 错误日志
        /// </summary>
        /// <param name="infor"></param>
        /// <param name="ex"></param>
        public static void WriteLog(string infor, Exception ex)
        {
            if (logError.IsErrorEnabled)
            {
                logError.Error(infor, ex);
            }
        }

        /// <summary>
        /// 信息日志
        /// </summary>
        /// <param name="infor"></param>
        public static void WriteLog(string infor)
        {
            if (logInfor.IsInfoEnabled)
            {
                logInfor.Info(infor);
            }
        }
    }
}
